import { authStoe } from '@/stores'
import router from '@/router'
import { ElMessageBox } from 'element-plus'

// 路由挂载比store挂载早。不能直接初始化
let auth = null
const getToken = () => {
  if (auth === null) {
    auth = authStoe()
  }
  return !!auth.token
}
const getRole = (name) => {
  if (auth === null) {
    auth = authStoe()
  }
  if (!auth.routes) return false
  if (auth.routes === '*') return true
  return auth.routes.indexOf(name) !== -1
}

router.beforeEach(async (to, from, next) => {
  next()
})

export default router
